If bridge name hasn't been recorded in XendConfig then try and work it out using...
authorTom Wilkie <tom.wilkie@gmail.com>
Wed, 25 Apr 2007 12:55:18 +0000 (13:55 +0100)
committerTom Wilkie <tom.wilkie@gmail.com>
Wed, 25 Apr 2007 12:55:18 +0000 (13:55 +0100)
This is needed when a VIF is created without specifying a bridge.

signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>

tools/python/xen/xend/XendDomainInfo.py

index 97e180f56248e7c2415f2423823ebab6e1d06c42..0c519a4ee43b50bd76a376a0f89c4d07e3fdaf44 100644 (file)
@@ -2246,9 +2246,18 @@ class XendDomainInfo:
 
             if not config.has_key('network'):
                 try:
+                    bridge = config.get('bridge', None)
+                    if bridge is None:
+                        from xen.util import Brctl
+                        if_to_br = dict([(i,b)
+                            for (b,ifs) in Brctl.get_state().items()
+                                for i in ifs])
+                        vifname = "vif%s.%s" % (self.getDomid(),
+                                                config.get('id'))
+                        bridge = if_to_br.get(vifname, None)
                     config['network'] = \
                         XendNode.instance().bridge_to_network(
-                        config.get('bridge')).uuid
+                        config.get('bridge')).get_uuid()
                 except Exception:
                     log.exception('bridge_to_network')
                     # Ignore this for now -- it may happen if the device